<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            background-color: black;
        }
    </style>
</head>
<body>
    <div></div>
    <script>
        // 行内样式权重高
        var div = document.querySelector('div');
        var flag = 0;
        div.onclick = function(){
            if(flag == 0){
                this.style.backgroundColor = 'blue';
                this.style.width = '200px';
                flag = 1;
            }else{
                this.style.backgroundColor = 'black';
                this.style.width = '100px';
                flag = 0;
            }
        }
    </script>
</body>
</html>